package co.fitstart.coach.entity.security;

import org.apache.commons.lang3.StringUtils;

import co.fitstart.entity.principal.Principal;

/**
 * 
 * @author downpour
 */
public class Login {
    
    private Long id;
    
    private String mobile;
    
    private String name;
    
    private String avatar;
    
    private String authority;
    
    /**
     * The default constructor
     */
    public Login() {
        
    }

    /**
     * 
     * @param principal
     */
    public Login (Principal principal) {
        this.id = principal.getId();
        this.name = principal.getName();
        if(principal.getProfile() != null) {
            this.avatar = principal.getProfile().getAvatar();
        }
        this.authority = principal.getAuthority();
        this.mobile = principal.getMobile();
    }
    
    /**
     * 
     * @return
     */
    public boolean isCoach() {
        return StringUtils.equalsIgnoreCase("ROLE_COACH", this.authority);
    }

    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @return the mobile
     */
    public String getMobile() {
        return mobile;
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @return the avatar
     */
    public String getAvatar() {
        return avatar;
    }

    /**
     * @return the authority
     */
    public String getAuthority() {
        return authority;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @param mobile the mobile to set
     */
    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @param avatar the avatar to set
     */
    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    /**
     * @param authority the authority to set
     */
    public void setAuthority(String authority) {
        this.authority = authority;
    }
    
    
}
